package cvslogic;

import java.io.File;

import com.pavelvlasov.uml.CompositeAcceptor;
import com.pavelvlasov.uml.Model;
import com.pavelvlasov.uml.eval.PrefixedCompositeEvaluator;
import com.pavelvlasov.uml.xmi.ModelBuilder;
import com.pavelvlasov.uml.xmi.PrintStreamLogger;

import cvslogic.elements.ComparePackage;

;

public class MainSystem {
	private File xmiFileNew = null;
	private File xmiFileOld = null;
	private Model newVersion = null;
	private Model oldVersion = null;
	private ComparePackage comparePackage = new ComparePackage();

	public static void main(String[] args) {
		MainSystem teste = new MainSystem();
		teste.setXMIVersions("Modelos/ModeloSistema.xml",
				"Modelos/ModeloSistema2.xml");
		teste.loadModels();
		teste.compare(teste.getNewVersion(), teste.getOldVersion());

	}

	public Model getNewVersion() {
		return this.newVersion;
	}

	public Model getOldVersion() {
		return this.oldVersion;
	}

	public void setXMIVersions(String newPath, String oldPath) {
		this.xmiFileNew = new File(newPath);
		this.xmiFileOld = new File(oldPath);
	}

	public void loadModels() {
		this.newVersion = ModelBuilder.loadModel(this.xmiFileNew,
				new CompositeAcceptor(), new PrintStreamLogger(),
				new PrefixedCompositeEvaluator());
		this.oldVersion = ModelBuilder.loadModel(xmiFileOld,
				new CompositeAcceptor(), new PrintStreamLogger(),
				new PrefixedCompositeEvaluator());
	}

	public void compare(Model newModel, Model oldModel) {
		/*
		 * for (Object e : ((Package)
		 * model.getPackages().toArray()[0]).getAssociationEnds().toArray()) {
		 * System.out.println(((Element) e).getName()); }
		 */

		comparePackage.compareVersions(newModel, oldModel);

	}
}
